﻿PRINT N'Creating [dbo].[RepAnalizKpo_]'
GO
CREATE FUNCTION RepAnalizKpo_ 
(	@D_S datetime,
	@D_PO datetime, 
	@K_SPEC int,
	@K_RAB int
) 
RETURNS TABLE
as RETURN (SELECT * 
FROM vRepAnalizKpo_
WHERE D_OBRASCH between @D_S and @D_PO 
and (isnull(@K_SPEC,0) = K_SPEC or @K_SPEC is null or @K_SPEC = 0)
and (isnull(@K_RAB,0) = K_RAB or @K_RAB is null or @K_RAB = 0)) 
GO
